<template>
  <div class="practiceIntroduction">
    <slot></slot>
    <ul>
      <li v-for="item in personMessageList" :key="item.id">
        {{ item.name }}--{{ item.age }}
      </li>
    </ul>
    <h2>{{ adress }}</h2>
    <br />
    <img
      class="dogPicture"
      v-for="(item, index) in dogList"
      :src="item"
      :key="index"
    />
    <br />
    <button @click="getDog">获取一只柯基</button>
  </div>
  <slot name="days" :interval="15"></slot>
</template>

<script lang="ts">
export default {
  name: "PracticeIntroduction",
};
</script>
<script lang="ts" setup>
import { defineProps, withDefaults } from "vue";
import { type PersonMessageList } from "@/type";
import useDog from "@/hooks/useDog";
// 1.接受props 并缓存
// const props = defineProps(["personMessageList"]);
// console.log(props);
// 2.接受props
// defineProps(["personMessageList"]);
// 3.接受props+限制类型+必要性
// defineProps<{ personMessageList?: PersonMessageList }>();
// 4.接受props+限制类型+必要性 + 默认值
withDefaults(
  defineProps<{ personMessageList?: PersonMessageList; adress?: string }>(),
  {
    personMessageList: () => [{ id: "0004", name: "刘亮", age: 66 }],
    adress: "伊通",
  }
);
let { dogList, getDog } = useDog();
</script>

<style scoped>
.practiceIntroduction {
  background-color: rgb(12, 234, 142);
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}
.dogPicture {
  height: 100px;
  margin-right: 5px;
}
</style>
